Walkthrough 4-7: Synchronize changes to an API specification between Anypoint Studio and Anypoint Platform
In this walkthrough, you synchronize changes to an API specification between Anypoint Studio, Design Center, and Anypoint Exchange. You will:
· Create an editable version of an API specification in Anypoint Studio.
· Make changes to an API specification in Anypoint Studio.
· Push the changes from Anypoint Studio to Design Center.
· Publish the modified API specification from Anypoint Studio to Exchange.
· Update the version of an API specification used in a Mule project.
· Rescaffold an API interface from an updated API specification.
Starting file
If you did not complete the previous walkthrough, you can get an Anypoint Studio starting file here. If you have not developed an American Flights API to add to your project, you can also get an API Designer starting file here. These files are also located in the solutions folder of the student files ZIP located in the Course Resources. Use these two starting files while following the steps in the addendum following this walkthrough.
Make the imported API specification editable in Anypoint Studio in a new API project
1. Return to the training4-american-ws project in Anypoint Studio.
2. Open american-flights-api.raml and try to make changes to the code; you should NOT be able to make any changes.
3. Right-click american-flights-api.raml in the Package Explorer and select American Flights API > Edit API specification.
4. In the Import API Specification dialog box, click Continue.
5. Locate the new American-Flights-API project that was created in the Package Explorer; its american-flights-api.raml file should have automatically opened.
Make changes to the API specification in Anypoint Studio
6. Return to the course snippets.txt file and copy the American Flights API - /{ID} PUT method.
7. Return to american-flights-api.raml in the new American-Flights-API project in Anypoint Studio.
8. Paste the put method that you copied after the {ID}/delete method.
9. Fix the indentation if necessary.
10. Review the code.
11. Save the file.
Review the Git Staging view for the API project
12. Locate the new Git Staging view that opened in Anypoint Studio.
13. Examine the Unstaged Changes section; you should see the american flights-api.raml file that is not yet staged for synchronization.
Review the API specification that was imported into the Mule project
14. Return to the training4-american-ws project.
15. Review the american-flights-api.raml file in that project; you should NOT see the new put method.
Push the changes for the modified API from Anypoint Studio to Design Center
16. Return to the Git Staging view.
17. Click the Add selected files to the index button in the upper-right corner of the Unstaged Changes section; the american-flights-api.raml file should move from the Unstaged Changes section to the Staged Changes section.
18. In the Commit Message section, enter the text Add PUT method.
19. Click the Commit and Push button; the Staged Changes section should now be empty.
20. In the Push Results dialog box, examine the commit log messages.
21. Click Close.
Examine the synchronized changes in API Designer
22. Return to your American Flights API in API Designer.
23. Notice the addition of the PUT method after the {ID}/delete method.
Note: If you do not see the PUT method, refresh the page.
Publish the modified API to Exchange from Anypoint Studio
24. Return to Anypoint Studio.
25. In the Package Explorer, right-click the American-Flights-API project and select Publish to Exchange.
26. In the API configuration dialog box, notice that Last published version is 1.0.1.
27. Set the Asset version to 1.0.2.
28. Click Finish.
29. Wait until the API publishes to Exchange and then in the Publish your API to Exchange dialog box that appears, click OK.
30. In the Package Explorer, right-click the American-Flights-API project and select Close Project.
31. Close the Git Staging view.
Examine the new published API asset version in Exchange
32. Return to your American Flights API in Exchange.
33. In the left-side navigation, click Home to return to the API portal for American Flights API.
34. Locate the asset versions listed for the API; you should see the new 1.0.2 asset version with an associated API instance using the mocking service.
Note: If you do not see the 1.0.2 asset version, refresh the page.
Update the API portal information
35. Click the Edit button for the API in the upper-right corner.
36. Add the new update a flight operation.
37. Click Save as draft and then Publish.
Review the API specification that was imported into the Mule project again
38. Return to the training4-american-ws project in Anypoint Studio.
39. Locate the American Flights API in the training4-american-ws project and notice that it is still v1.0.1.
40. Review the american-flights-api.raml file; you should still NOT see the new put method.
Update the version of the API used in the Mule project and rescaffold the flows
41. Right-click American Flights API in the training4-american-ws project and select American Flights API > Update Version.
42. In the Properties for training4-american-ws dialog box, select the American Flights API; an Update version button should appear.
43. Click Update version; the version of the API should change to 1.0.2.
44. Click Apply and Close.
45. In the dialog box that appears, click Yes to scaffold American Flights API specification.
46. When the scaffolding is complete, return to interface.xml and review the flows; you should now see five method flows, including the new put:\flights\{ID} method.
47. Look at the get:\flights\{ID} method; it was not overwritten and still has your change to use a Flow Reference component.
Starting File Addendum (only needed if you did not complete Walkthrough 4-6)
Create your editable API in Exchange with the correct asset number
1. In API Designer, create American Flights API then import wt3-4_American-Flights-API_solution.zip electing to replace american-flights-api.raml.
2. Publish the API to Exchange with an asset/version of 1.0.1/v1.
Create your Studio application and replace the static API with your editable API
3. In Studio, import wt4-6_training4-american-ws_solution.jar.
4. Right-click the project and select Manage Dependencies > Manage APIs to delete Training: American Flights API and to add your American Flights API from Exchange.
Note: Be sure to scaffold your American Flights API when prompted.
Transfer the flow references from the old scaffold to the new
5. Copy/paste the flow reference from interface.xml get:\flights to its corresponding location in american-flights-api-2.xml replacing any transforms.
6. Repeat for the get:\flights\(ID) flow reference.
Remove the old scaffolding and configure the new scaffolding
7. Delete interface.xml and refactor/rename american-flights-api-2.xml to interface.xml.
8. Set the main Listener in interface.xml to use the configuration HTTP_Listener_config.
9. Save your changes; you should now be ready to perform this walkthrough.
Note: When using these starting files, walkthrough steps such as updating the API portal information in Exchange may not match the screenshots.